package com.lhgray.sglhome.data.network.api

import com.freightoa.foundation.net.ApiResult
import com.freightoa.foundation.net.bean.SGLResponse
import com.lhgray.sglhome.domain.model.HomeBean
import com.lhgray.sglhome.domain.model.SourceData
import com.lhgray.sglhome.domain.model.TruckingBean
import com.lhgray.sglhome.domain.model.WarehouseBean
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.PartMap
import retrofit2.http.Path
import retrofit2.http.Query

interface HomeServer {
    /**
     * 登录接口的封装
     */
    @POST("/MiddlewareAPI/v{version}/StarcoAir/GetTokenByUser")
    suspend fun getLogin(
        @Query("login_name") loginName: String,
        @Query("password") password: String,
        @Path("version") version: String,
    ): ApiResult<HomeBean>

    @POST("/MiddlewareAPI/v{version}/StarcoAir/GetTokenByUser")
    suspend fun uploadPic(
        @PartMap description: Map<String, RequestBody>, @Part file: MultipartBody.Part
    ): ApiResult<String>

    @POST("/MiddlewareAPI/v{version}/StarcoAir/GetStandardJob")
    suspend fun getOrderList(
        @Path("version") version: String,
        @Query("file_no") fileNo: String,
    ): ApiResult<SGLResponse<SourceData>>

    @POST("/MiddlewareAPI/v{version}/StarcoAir/GetWarehouseJob")
    suspend fun getWarehouseJob(
        @Path("version") version: String,
        @Query("file_no") fileNo: String,
    ): ApiResult<SGLResponse<WarehouseBean>>

    @POST("/MiddlewareAPI/v{version}/StarcoAir/PostWarehouseJob")
    suspend fun postWarehouseJob(
        @Path("version") version: String,
        @Body fileNo: WarehouseBean,
    ): ApiResult<SGLResponse<String>>

    @POST("/MiddlewareAPI/v{version}/StarcoAir/GetTruckingJob")
    suspend fun getTruckingJob(
        @Path("version") version: String,
        @Query("file_no") fileNo: String,
    ): ApiResult<SGLResponse<TruckingBean>>

    @POST("/MiddlewareAPI/v{version}/StarcoAir/PostTruckingJob")
    suspend fun postTruckingJob(
        @Path("version") version: String,
        @Body fileNo: TruckingBean,
    ): ApiResult<SGLResponse<String>>

    @Multipart
    @POST("/MiddlewareAPI/v{version}/StarcoAir/PostMemo")
    @JvmSuppressWildcards
    suspend fun postMemo(
        @Path("version") version: String,
        @PartMap description: Map<String, RequestBody>,
        @Part files: List<MultipartBody.Part>
    ): ApiResult<SGLResponse<String>>

    @POST("/MiddlewareAPI/v{version}/StarcoAir/GetFileNoByBarcode")
    @JvmSuppressWildcards
    suspend fun getFileNoByBarcode(
        @Path("version") version: String,
        @Query("barcode") fileNo: String
    ): ApiResult<SGLResponse<SourceData>>
}